#pragma once

#include "ScriptCompiler/ASTBuilder/ASTBuilder.h"

class CTypeNode;
class CScriptFileContext;


class CTypeBuilder : public IASTBuilder
{
public:
    CTypeBuilder(std::shared_ptr<CScriptFileContext> InContext,bool bInResumeIfNotAType=false);

    virtual bool ReadCurentToken() override;

    std::shared_ptr<CTypeNode> Result;
    
    //detect type from current token
    //if might be a type, return the first token index after the type
    //if impossible to be a type, return -1
    static int64_t DetectType(std::shared_ptr<CScriptFileContext> InContext,int64_t StartTokenIndex);
protected:
    
    std::shared_ptr<CScriptFileContext> Context;

    //if build failed, just resume the Token index to the first token , will not treat as a error
    bool bResumeIfNotAType;
    uint64_t FirstTokenIndex;
    void PostTypeTestFailed();
};